import request from '@/utils/request'

// 查询流程列表
export function listProcess(query) {
  return request({
    url: "/system/workflow/process/list",
    method: "get",
    params: query,
  });
}
// 查询条形码
export function listProcessGen(query) {
  return request({
    url: "/system/workflow/process/gen",
    method: "get",
    params: query,
    responseType: "blob",
  });
}

// 查询流程列表
export function getProcessForm(query) {
  return request({
    url: "/system/workflow/process/getProcessForm",
    method: "get",
    params: query,
  });
}

// 暂存表单
export function getProcessFormHold(processDefId, data, Code, businessKey) {
  let processUrl = "/system/workflow/process/hold/" + processDefId + "/" + Code
  if(businessKey){
    processUrl += "/" + businessKey
  }
  return request({
    url: processUrl,
    method: "post",
    data: data,
  });
}
// 发起申请
export function startProcess(processDefId, data,Code,businessKey) {
  let processUrl = "/system/workflow/process/start/" + processDefId + "/" + Code
  if(businessKey){
    processUrl += "/" + businessKey
  }
  return request({
    url: processUrl,
    method: "post",
    data: data,
  });
}

// 获取流程图
export function getBpmnXml(processDefId) {
  return request({
    url: "/system/workflow/process/bpmnXml/" + processDefId,
    method: "get",
  });
}

export function detailProcess(query) {
  return request({
    url: "/system/workflow/process/detail",
    method: "get",
    params: query,
  });
}

// 我的发起的流程
export function listOwnProcess(query) {
  return request({
    url: "/system/workflow/process/ownList",
    method: "get",
    params: query,
  });
}

// 我待办的流程
export function listTodoProcess(query) {
  return request({
    url: "/system/workflow/process/todoList",
    method: "get",
    params: query,
  });
}

// 我待签的流程
export function listClaimProcess(query) {
  return request({
    url: "/system/workflow/process/claimList",
    method: "get",
    params: query,
  });
}

// 我已办的流程
export function listFinishedProcess(query) {
  return request({
    url: "/system/workflow/process/finishedList",
    method: "get",
    params: query,
  });
}

// 查询流程抄送列表
export function listCopyProcess(query) {
  return request({
    url: "/system/workflow/process/copyList",
    method: "get",
    params: query,
  });
}

// 取消申请
export function stopProcess(data) {
  return request({
    url: "/system/workflow/task/stopProcess",
    method: "post",
    data: data,
  });
}

// 删除流程实例
export function delProcess(id) {
  return request({
    url: "/system/workflow/instance/delete/?instanceId=" + id,
    method: "delete",
  });
}
// 流程实例
export function detail(procInsId) {
  return request({
    url: "/workflow/process/detail/" + procInsId,
    method: "delete",
  });
}
